<?php
namespace app\api\controller\admin;
use app\api\controller\Controller;
use app\api\model\User as UserModel;
//use app\api\model\Comment as CommentModel;
use app\api\model\Order as OrderModel;
use app\api\model\ShopClerk as ShopClerkModel;

/**
 * 商户管理中心
 */
class Store extends Controller
{
    /**
     * 商户数据统计
     */
    public function getCount($shop_id)
    {
		// 当前用户信息
        $userInfo = $this->getUser();
		$count = array();
		$count['order'] = OrderModel::getAllCount($shop_id);	//订单和收入统计
		$count['comment'] = [0,0];//CommentModel::getCount();	//评价
		$count['user'] = UserModel::getCount();	//用户统计
        return $this->renderSuccess(compact('count'));  
    }
	
	/**
     * 店员一键登录
     */
    public function login()
    {
		// 当前用户信息
        $userInfo = $this->getUser();
		$clerk = ShopClerkModel::detail(['user_id' => $userInfo['user_id']]);
		if($clerk){
			return $this->renderSuccess(compact('clerk')); 
		}
		return $this->renderError('店员不存在');
    }
}
